﻿<%@ Page Language="C#" MasterPageFile="~/Shared/EOS.master" AutoEventWireup="True"
    Inherits="EOSCRM.Web.Forms.DongHo.ThayDongHo" CodeBehind="ThayDongHo.aspx.cs" %>

<%@ Import Namespace="EOSCRM.Web.Common" %>
<%@ Import Namespace="EOSCRM.Util" %>


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="../../UserControls/FilterPanel.ascx" TagName="FilterPanel" TagPrefix="bwaco" %>
<%@ Register Assembly="EOSCRM.Controls" Namespace="EOSCRM.Controls" TagPrefix="eoscrm" %>

<asp:Content ID="head" ContentPlaceHolderID="headCPH" runat="server">

    <script type="text/javascript">
        $(document).ready(function() {
            $("#divNhanVien").dialog({
                autoOpen: false,
                modal: true,
                minHeight: 100,
                height: 'auto',
                width: 'auto',
                resizable: false,
                open: function(event, ui) {
                    $(this).parent().appendTo("#divNhanVienDlgContainer");
                }
            });
        });
        $(document).ready(function() {
        $("#divThongTinTDH").dialog({
                autoOpen: false,
                modal: true,
                minHeight: 100,
                height: 'auto',
                width: 'auto',
                resizable: false,
                open: function(event, ui) {
                $(this).parent().appendTo("#divThongTinTDHDlgContainer");
                }
            });
        });
        function OpenTTTT() {
            openWaitingDialog();
            unblockWaitingDialog();

            __doPostBack('<%= CommonFunc.UniqueIDWithDollars(linkdetail) %>', '');

            return false;
        }
        function CheckFormFilterNV() {
            openWaitingDialog();
            unblockWaitingDialog();

            __doPostBack('<%= CommonFunc.UniqueIDWithDollars(btnFilterNV) %>', '');

            return false;
        }
        $(document).ready(function() {
            $("#divNhanVienBB").dialog({
                autoOpen: false,
                modal: true,
                minHeight: 100,
                height: 'auto',
                width: 'auto',
                resizable: false,
                open: function(event, ui) {
                    $(this).parent().appendTo("#divNhanVienBBDlgContainer");
                }
            });
        });
        function CheckFormFilterNVBB() {
            openWaitingDialog();
            unblockWaitingDialog();

            __doPostBack('<%= CommonFunc.UniqueIDWithDollars(btnFilterNV) %>', '');

            return false;
        }
        function CheckFormFilterKH() {
            var idkh = jQuery.trim($("#<%= txtIDKH.ClientID %>").val());
            var tenkh = jQuery.trim($("#<%= txtTENKH.ClientID %>").val());
            var madh = jQuery.trim($("#<%= txtMADH.ClientID %>").val());
            var sohd = jQuery.trim($("#<%= txtSOHD.ClientID %>").val());
            var sonha = jQuery.trim($("#<%= txtSONHA.ClientID %>").val());
            var tendp = jQuery.trim($("#<%= txtTENDP.ClientID %>").val());
            var makv = jQuery.trim($("#<%= ddlKHUVUC.ClientID %>").val());

            if (idkh == '' && tenkh == '' && madh == '' &&
                    sohd == '' && sonha == '' && tendp == '' && (makv == '' || makv == 'NULL')) {
                showError('Chọn tối thiểu một thông tin để lọc khách hàng.', '<%= txtIDKH.ClientID %>');
                return false;
            }

            openWaitingDialog();
            unblockWaitingDialog();

            __doPostBack('<%= CommonFunc.UniqueIDWithDollars(btnFilterKH) %>', '');

            return false;
        }

        function CheckChangeKH(e) {
            var code = (e.keyCode ? e.keyCode : e.which);
            jQuery.fn.exists = function() { return jQuery(this).length > 0; }
            if (code == 13) {
                openWaitingDialog();
                unblockWaitingDialog();
                __doPostBack('<%= CommonFunc.UniqueIDWithDollars(txtSODB) %>', '');
            }
        }

        function CheckSearchKH() {
            openWaitingDialog();
            unblockWaitingDialog();
            __doPostBack('<%= CommonFunc.UniqueIDWithDollars(txtSODB) %>', '');

            return false;
        }
        
        function CheckFormSave() {

            openWaitingDialog();
            unblockWaitingDialog();

            __doPostBack('<%= CommonFunc.UniqueIDWithDollars(btnSave) %>', '');

            return false;
        }
        
        function CheckFormDelete() {

            if (CheckRecordSelected('delete')) {
                openWaitingDialog();
                unblockWaitingDialog();

                __doPostBack('<%= CommonFunc.UniqueIDWithDollars(btnDelete) %>', '');
            }

            return false;
        }
        
    </script>

</asp:Content>

<asp:Content ID="content" ContentPlaceHolderID="mainCPH" runat="server">
    <div id="divThongTinTDHDlgContainer">
        <div id="divThongTinTDH"  style="display:none">
            <asp:UpdatePanel ID="upnlThongTinTDH" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <table cellpadding="3" cellspacing="1" style="width: 800px;">
                        <tr>
							<td class="crmcontainer">
                        <eoscrm:Grid ID="gvThongTin" runat="server" UseCustomPager="true" PageSize="20" OnPageIndexChanging="gvThongTin_PageIndexChanging"
                    OnRowDataBound="gvThongTin_RowDataBound" >
                    <PagerSettings FirstPageText="Thông tin" PageButtonCount="2" />
                    <Columns>
                        <asp:TemplateField HeaderStyle-CssClass="checkbox" HeaderText="STT">
                            <ItemTemplate>
                                <%# Container.DataItemIndex + 1%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="18%" HeaderText="Tình trạng" >
                            <ItemTemplate>
                                <%# (Eval("TINHTRANG") != null) ? ((bool.Parse(Eval("TINHTRANG").ToString())==true)?"Đã thay":
    "Chưa thay"):"Chưa thay"%>
                            </ItemTemplate>
                            <HeaderStyle Width="18%" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="18%" HeaderText="Ngày LBB">
                            <ItemTemplate>
                                <%# (Eval("NGAYLBB") != null) ?
                                        String.Format("{0:dd/MM/yyyy}", Eval("NGAYLBB"))
                                        : "" %>
                            </ItemTemplate>
                            <HeaderStyle Width="18%" />
                        </asp:TemplateField> 
                        <asp:TemplateField HeaderStyle-Width="18%" HeaderText="Ngày thay">
                            <ItemTemplate>
                                <%# (Eval("NGAYTD") != null) ?
                                        String.Format("{0:dd/MM/yyyy}", Eval("NGAYTD"))
                                        : "" %>
                            </ItemTemplate>
                            <HeaderStyle Width="18%" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="23%" HeaderText="Ngày hoàn thành">
                            <ItemTemplate>
                                <%# (Eval("NGAYHT") != null) ?
                                     String.Format("{0:dd/MM/yyyy}", Eval("NGAYHT"))
                                        : "" %>
                            </ItemTemplate>
                            <HeaderStyle Width="18%" />
                        </asp:TemplateField>
                    </Columns>
                </eoscrm:Grid> 
                        </td>
                        </tr>
                        </table>
                </ContentTemplate>
                </asp:UpdatePanel>
        </div>
    </div>
    <div id="divNhanVienBBDlgContainer">
        <div id="divNhanVienBB" style="display:none">
            <asp:UpdatePanel ID="upnlNhanVienBB" runat ="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <table cellpadding="3" cellspacing="1" style="width: 800px;">
                        <tr>
                            <td class="crmcontainer">
                                <table class="crmtable">
                                    <tbody>
                                        <tr>
                                            <td class="crmcell right">
                                                Từ khóa
                                            </td>
                                            <td class="crmcell">
                                                <div class="left">
                                                    <asp:TextBox ID="txtKeywordNVBB" onchange="return CheckFormFilterNV();" runat="server" Width="250px" MaxLength="200" />
                                                </div>
                                                <div class="left">
                                                    <asp:Button ID="btnFilterNVBB" OnClick="btnFilterNVBB_Click"
                                                        UseSubmitBehavior="false" OnClientClick="return CheckFormFilterNVBB();" 
                                                        runat="server" CssClass="filter" Text="" />
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
						<tr>
							<td class="ptop-10">
							    <div class="crmcontainer">
							        <eoscrm:Grid ID="gvNhanVienBB" runat="server" UseCustomPager="true" 
							            OnRowDataBound="gvNhanVienBB_RowDataBound" OnRowCommand="gvNhanVienBB_RowCommand" 
							            OnPageIndexChanging="gvNhanVienBB_PageIndexChanging">
                                        <PagerSettings FirstPageText="nhân viên" PageButtonCount="2" />
                                        <Columns>
                                            <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Mã NV">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkBtnID" runat="server" 
                                                        CommandArgument='<%# Eval("MANV") %>' CommandName="SelectMANV"                                                         
                                                        Text='<%# HttpUtility.HtmlEncode(Eval("MANV").ToString()) %>'></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField HeaderStyle-Width="35%" DataField="HOTEN" HeaderText="Họ tên" />
                                            <asp:TemplateField HeaderStyle-Width="30%" HeaderText="Phòng ban">
                                                <ItemTemplate>
                                                    <%# Eval("PHONGBAN") != null ? Eval("PHONGBAN.TENPB") : "" %>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderStyle-Width="25%" HeaderText="Công việc">
                                                <ItemTemplate>
                                                    <%# Eval("CONGVIEC") != null ? Eval("CONGVIEC.TENCV") : ""%>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </eoscrm:Grid>
                                </div>
							</td>
						</tr>
					</table>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>
    <div id="divNhanVienDlgContainer">
        
        <div id="divNhanVien" style="display: none">
            
            <asp:UpdatePanel ID="upnlNhanVien" runat="server" UpdateMode="Conditional">
                
				<ContentTemplate>
				    <table cellpadding="3" cellspacing="1" style="width: 800px;">
                        <tr>
                            <td class="crmcontainer">
                                <table class="crmtable">
                                    <tbody>
                                        <tr>
                                            <td class="crmcell right">
                                                Từ khóa
                                            </td>
                                            <td class="crmcell">
                                                <div class="left">
                                                    <asp:TextBox ID="txtKeywordNV" onchange="return CheckFormFilterNV();" runat="server" Width="250px" MaxLength="200" />
                                                </div>
                                                <div class="left">
                                                    <asp:Button ID="btnFilterNV" OnClick="btnFilterNV_Click"
                                                        UseSubmitBehavior="false" OnClientClick="return CheckFormFilterNV();" 
                                                        runat="server" CssClass="filter" Text="" />
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
						<tr>
							<td class="ptop-10">
							    <div class="crmcontainer">
							        <eoscrm:Grid ID="gvNhanVien" runat="server" UseCustomPager="true" 
							            OnRowDataBound="gvNhanVien_RowDataBound" OnRowCommand="gvNhanVien_RowCommand" 
							            OnPageIndexChanging="gvNhanVien_PageIndexChanging">
                                        <PagerSettings FirstPageText="nhân viên" PageButtonCount="2" />
                                        <Columns>
                                            <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Mã NV">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkBtnID" runat="server" 
                                                        CommandArgument='<%# Eval("MANV") %>' CommandName="SelectMANV"                                                         
                                                        Text='<%# HttpUtility.HtmlEncode(Eval("MANV").ToString()) %>'></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField HeaderStyle-Width="35%" DataField="HOTEN" HeaderText="Họ tên" />
                                            <asp:TemplateField HeaderStyle-Width="30%" HeaderText="Phòng ban">
                                                <ItemTemplate>
                                                    <%# Eval("PHONGBAN") != null ? Eval("PHONGBAN.TENPB") : "" %>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderStyle-Width="25%" HeaderText="Công việc">
                                                <ItemTemplate>
                                                    <%# Eval("CONGVIEC") != null ? Eval("CONGVIEC.TENCV") : ""%>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </eoscrm:Grid>
                                </div>
							</td>
						</tr>
					</table>
					
				</ContentTemplate>
	        </asp:UpdatePanel>
        </div>
    </div>
    <div id="divKhachHangDlgContainer">
        <div id="divKhachHang" style="display: none">
            <asp:UpdatePanel ID="upnlKhachHang" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <table cellpadding="3" cellspacing="1" style="width: 610px;">
                        <tbody>
                            <tr>
                                <td>
                                    <asp:Panel ID="headerPanel" runat="server" CssClass="crmcontainer">
                                        <table class="crmtable">
                                            <tbody>
                                                <tr class="crmfilter">
                                                    <td class="crmcell">
                                                        <div class="wrap">
                                                            <asp:ImageButton ID="imgCollapse" runat="server" ImageUrl="~/content/images/icons/expanded.png"
                                                                AlternateText="Hiện bộ lọc" />
                                                        </div>
                                                        <div class="wrap">
                                                            <asp:Label ID="lblCollapse" runat="server">Click vào để hiển thị bộ lọc</asp:Label>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>    
                                    </asp:Panel>
                                    <asp:Panel ID="contentPanel" runat="server" CssClass="crmcontainer cleantop">
                                        <table class="crmtable">
                                            <tbody>
                                                <tr>
                                                    <td class="crmcell rightsmall">
                                                        Mã khách hàng
                                                    </td>
                                                    <td class="crmcell">
                                                        <div class="left">
                                                            <asp:TextBox ID="txtIDKH" runat="server" onchange="return CheckFormFilterKH();" CssClass="width-150" MaxLength="200" />
                                                        </div>
                                                        <div class="left width-100 pleft-50">
                                                            <div class="rightsmall">Tên khách hàng</div>
                                                        </div>
                                                        <div class="left">
                                                            <asp:TextBox ID="txtTENKH" runat="server" CssClass="width-150" MaxLength="200" />
                                                        </div>  
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="crmcell rightsmall">
                                                        Mã đồng hồ
                                                    </td>
                                                    <td class="crmcell">
                                                        <div class="left">
                                                            <asp:TextBox ID="txtMADH" runat="server" onchange="return CheckFormFilterKH();" CssClass="width-150" MaxLength="200" />
                                                        </div>
                                                        
                                                        <div class="left width-100 pleft-50">
                                                            <div class="rightsmall">Số hợp đồng</div>
                                                        </div>
                                                        <div class="left">
                                                            <asp:TextBox ID="txtSOHD" runat="server" onchange="return CheckFormFilterKH();" CssClass="width-150" MaxLength="200" />
                                                        </div>  
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="crmcell rightsmall">
                                                        Số nhà
                                                    </td>
                                                    <td class="crmcell">
                                                        <div class="left">
                                                            <asp:TextBox ID="txtSONHA" runat="server" onchange="return CheckFormFilterKH();" CssClass="width-150" MaxLength="200" />
                                                        </div>
                                                        <div class="left width-100 pleft-50">
                                                           <div class="rightsmall">Tên đường phố</div>
                                                        </div>
                                                        <div class="left">
                                                            <asp:TextBox ID="txtTENDP" runat="server" onchange="return CheckFormFilterKH();" CssClass="width-150" MaxLength="200" />
                                                        </div>  
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="crmcell rightsmall">
                                                        Khu vực
                                                    </td>
                                                    <td class="crmcell">
                                                        <div class="left">
                                                            <asp:DropDownList ID="ddlKHUVUC" runat="server"></asp:DropDownList>
                                                        </div>
                                                        <div class="left width-100 pleft-50">
                                                            <div class="rightsmall">
                                                                Phường :</div>
                                                        </div>
                                                        <div class="left">
                                                            <asp:DropDownList ID="ddlPHUONG" runat="server">
                                                            </asp:DropDownList>
                                                        </div>
                                                    </td>
                                                    
                                                </tr>
                                                <tr>
                                                    <%--<td class="crmcell right">Loại khách hàng</td>--%>
                                                    <td colspan="2" class="crmcell">
                                                        <div class="left">
                                                           <strong> Loại khách hàng</strong>
                                                        </div>
                                                        <div class="left">
                                                            <asp:DropDownList runat="server" ID="ddlLoaiKhachHang" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="crmcell rightsmall"></td>
                                                    <td class="crmcell">
                                                        <div class="left">
                                                            <asp:Button ID="btnFilterKH" OnClick="btnFilterKH_Click"
                                                                UseSubmitBehavior="false" OnClientClick="return CheckFormFilterKH();" 
                                                                runat="server" CssClass="filter" Text="" />
                                                        </div>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </asp:Panel>
                                    <ajaxToolkit:CollapsiblePanelExtender ID="cpeFilter" runat="Server" 
                                        Collapsed="false"
                                        TargetControlID="contentPanel"
                                        ExpandControlID="headerPanel" 
                                        CollapseControlID="headerPanel" 
                                        TextLabelID="lblCollapse"
                                        ImageControlID="imgCollapse" 
                                        ExpandedText="Click vào để ẩn bộ lọc" 
                                        CollapsedText="Click vào để hiển thị bộ lọc"
                                        ExpandedImage="~/content/images/icons/collapsed.png" 
                                        CollapsedImage="~/content/images/icons/expanded.png" />
                                </td>
                            </tr>
                            <tr>
                                <td class="ptop-10" id="tdDanhSach" runat="server" visible="false">
                                    <div class="crmcontainer">                                   
                                        <eoscrm:Grid ID="gvDanhSach" runat="server" UseCustomPager="true" 
							                OnPageIndexChanging="gvDanhSach_PageIndexChanging" 
							                OnRowDataBound="gvDanhSach_RowDataBound" OnRowCommand="gvDanhSach_RowCommand">
                                            <PagerSettings FirstPageText="khách hàng" PageButtonCount="2" />
                                            <Columns>
                                                <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Mã KH">
                                                    <ItemTemplate>
                                                        <asp:LinkButton ID="lnkBtnID" runat="server" CommandName="SelectSODB" 
                                                            CommandArgument='<%# Eval("IDKH") %>'
                                                            Text='<%# Eval("MADP") + Eval("DUONGPHU").ToString() + Eval("MADB") %>'></asp:LinkButton>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:BoundField HeaderStyle-Width="35%" DataField="TENKH" HeaderText="Tên khách hàng" />
                                                <asp:TemplateField HeaderStyle-Width="55%" HeaderText="Địa chỉ">
                                                    <ItemTemplate>
                                                        <%# Eval("SONHA") != null ? Eval("SONHA") + ", " : "" %>
                                                        <%# Eval("DUONGPHO") != null ? Eval("DUONGPHO.TENDP") + ", " : "" %>
                                                        <%# Eval("KHUVUC") != null ? Eval("KHUVUC.TENKV") : "" %>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </eoscrm:Grid>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>
    <asp:UpdatePanel ID="upnlThongTin" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            <div class="crmcontainer">
                <table class="crmtable">
                    <tbody>
                        <tr>    
                            <td class="crmcell right">Mã khách hàng</td>
                            <td class="crmcell">    
                                <div class="left">
                                    <asp:TextBox ID="txtSODB" runat="server" OnTextChanged="txtSODB_TextChanged" onchange="CheckSearchKH();" MaxLength="8" Width="90px" TabIndex="7" />
                                </div>
                                <div class="left">
                                    <asp:Button ID="btnBrowseKH" runat="server" CssClass="pickup" OnClick="btnBrowseKH_Click"
                                        CausesValidation="false" UseSubmitBehavior="false" 
                                        OnClientClick="openDialogAndBlock('Chọn từ danh sách khách hàng', 610, 'divKhachHang')" 
                                        TabIndex="6" />
                                    <asp:LinkButton ID="linkdetail" runat="server" Text="Click xem chi tiết" 
                                        ForeColor="Red" onclick="linkdetail_Click" 
                                        OnClientClick="openDialogAndBlock('Thông tin thay đồng hồ', 750, 'divThongTinTDH')" 
                                        Visible="False"></asp:LinkButton>
                                    <div style="display:none"><asp:TextBox ID="txtId" runat="server"></asp:TextBox></div>
                                </div>
                            </td>
                        </tr>
                        <tr>    
                            <td class="crmcell right">Tên khách hàng</td>
                            <td class="crmcell">    
                                <div class="left" style="width:200px">
                                    <asp:Label ID="lblTENKH" runat="server" Text=""></asp:Label>
                                </div>
                                <div class="left">
                                    <div class="right"></div>
                                </div>
                                <div class="left">
                                    
                                </div>
                            </td>
                        </tr>
                        <tr>    
                            <td class="crmcell right">Đường phố</td>
                            <td class="crmcell">    
                                <div class="left width-200">
                                    <asp:Label ID="lblTENDP" runat="server" Text=""></asp:Label>
                                </div>
                                <div class="left">
                                    <div class="right">Khu vực</div>
                                </div>
                                <div class="left">
                                    <asp:Label ID="lblTENKV" runat="server" Text=""></asp:Label>
                                </div>
                            </td>
                        </tr>
                                               
                        <tr>
                            <td class="crmcell right">
                                Nội dung công việc</td>
                            <td class="crmcell">
                                <div class="left width-200">
                                    <asp:DropDownList ID="ddlNoiDungCongViec" runat="server" AutoPostBack="True">
                                        <asp:ListItem Value="TM">Thay mới</asp:ListItem>
                                        <asp:ListItem Value="BH">Bảo Hành</asp:ListItem>
                                    </asp:DropDownList>
                                </div>
                                <div class="left">
                                    <div class="right">Lý do thay</div>
                                </div>
                                <div class="left">
                                     <asp:DropDownList ID="ddlLydoThay" runat="server">
                                    </asp:DropDownList>
                                </div>
                                <div class="left"><b>
                                    Tình trạng</b>
                                </div>
                                <div class="left">
                                    <asp:CheckBox ID="checktinhtrang" Text="Đã thay" Checked="true" runat="server" />
                                </div>
                                </td>
                        </tr>
                                               
                        <tr>    
                            <td class="crmcell right">Ngày lập biên bản</td>
                            <td class="crmcell">    
                                <div class="left width-200">
                                <asp:TextBox ID="txtNgayLapBienBan" tag="datevn" runat="server" Width="90px"></asp:TextBox>
                                  
                                    
                                </div>
                                <div class="left">
                                    <div class="right">Ngày thay</div>
                                </div>
                                <div class="left">
                                    <asp:TextBox ID = "txtNgayThay" tag="datevn" runat ="server" Width="90px" />
                                    
                                </div>
                                <div class="left">
                                    <div class="right">Ngày hoàn thành</div>
                                </div>
                                <div class="left">
                                    
                                     <asp:TextBox ID = "txtNgayHoanThanh"  tag="datevn" runat ="server" Width="90px" />
                                     
                                         
                                </div>
                                
                            </td>
                        </tr>
                        
                        <tr>
                            <td class="crmcell right">
                                Phiếu xuất</td>
                            <td class="crmcell">
                            <div class="left width-200">
                                <asp:TextBox ID="txtSoPhieu" runat="server"></asp:TextBox>
                                </div>
                                <div class="left">
                                    <div class="right">Ngày xuất kho</div>
                                </div>
                                <div class="left">
                                    <asp:TextBox ID="txtNgayXuat"  tag="datevn" runat="server"></asp:TextBox>
                                    
                                </div>
                            </td>
                        </tr>
                        
                        <tr>    
                            <td class="crmcell right">Loại đồng hồ</td>
                            <td class="crmcell">    
                                <div class="left width-200">
                                    <asp:DropDownList ID= "cboLoaiDh" runat ="server" Width="102px"></asp:DropDownList>
                                </div>
                                <div class="left">
                                    <div class="right">Cỡ đồng hồ</div>
                                </div>
                                <div class="left">
                                     <asp:DropDownList ID="ddlKICHCODH" Width="102px" runat="server" TabIndex="21">
                                        <asp:ListItem Text="15" Value="15" />
                                        <asp:ListItem Text="20" Value="20" />
                                        <asp:ListItem Text="25" Value="25" />
                                        <asp:ListItem Text="34" Value="34" />
                                        <asp:ListItem Text="42" Value="42" />
                                        <asp:ListItem Text="49" Value="49" />
                                        <asp:ListItem Text="60" Value="60" />
                                        <asp:ListItem Text="100" Value="100" />
                                    </asp:DropDownList>
                                </div>
                                
                            </td>
                        </tr>
                        
                        <tr>    
                            <td class="crmcell right">Mã đồng hồ</td>
                            <td class="crmcell">    
                                <div class="left width-200">
                                    <asp:TextBox ID = "txtMaDongho" runat ="server" Width="90px" />
                                </div>
                                <div class="left">
                                    <div class="right">Số tem</div>
                                </div>
                                <div class="left">
                                     <asp:TextBox ID = "txtSoTem" runat ="server" Width="90px" />
                                </div>
                                
                            </td>
                        </tr>
                          
                        <tr>
                            <td class="crmcell right">Nơi sản xuất</td>
                            <td class="crmcell">    
                                <div class="left width-200">
                                    <asp:TextBox ID = "txtNoiSanXuat" runat ="server" Width="90px" />
                                </div>
                                <div class="left">
                                    <div class="right">ĐV kiểm định</div>
                                </div>
                                <div class="left">
                                     <asp:TextBox ID = "txtDonViKiemDinh" runat ="server" Width="90px" />
                                </div>
                                
                            </td>
                        </tr>
                        <tr>
                            <td class="crmcell right">Chỉ số cũ</td>
                            <td class="crmcell">    
                                <div class="left width-200">
                                    <asp:TextBox ID = "txtChiSoCu" runat ="server" Width="90px" />
                                </div>
                                <div class="left">
                                    <div class="right">Chỉ số mới</div>
                                </div>
                                <div class="left">
                                     <asp:TextBox ID = "txtChiSoMoi" runat ="server" Width="90px" />
                                </div>
                                
                            </td>
                        </tr>
                        <tr>
                            <td class="header bbottom" colspan="2">
                            <b>KHÁCH HÀNG MUA MỚI</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <asp:CheckBox ID="checkMuaMoi" runat="server" />
                            </td>
                        </tr>
                        
                        <tr>
                            <td class="crmcell right">Số lượng</td>
                            <td class="crmcell">    
                                <div class="left">
                                        <asp:TextBox ID="txtSoLuong" Text="1" runat="server"></asp:TextBox>
                                </div>
                                <div class="left">
                                    <div class=" crmcell right">Số tiền
                                        <asp:TextBox ID="txtSoTien" Width="70px" runat="server"></asp:TextBox>
                                     </div>
                                </div>
                                <div class="left">
                                    <div class="crmcell right">Tiền nhân công
                                        <asp:TextBox ID="txtNhanCong" Text="50000" runat="server"></asp:TextBox>
                                        </div>
                                </div>
                            </td>
                        </tr>
                          
                        <tr>
                            <td class="crmcell right">
                                Nhân viên thực hiện</td>
                            <td class="crmcell">
                                <div class="left width-250">
                                    <asp:TextBox ID="txtNhanVienTH" runat="server" Width="90px" />
                                    <asp:Button ID="btnBrowseNhanVien" runat="server" CausesValidation="false" 
                                        CssClass="pickup" OnClick="btnBrowseNhanVien_Click" 
                                        OnClientClick="openDialogAndBlock('Chọn từ danh sách nhân viên', 800, 'divNhanVien')" 
                                        UseSubmitBehavior="false" />
                                    <asp:TextBox ID="txtTenNhanVien" runat="server" ReadOnly="True"></asp:TextBox>
                                </div>
                                <div class="left">
                                    <div class="right">
                                        Hạn kiểm định</div>
                                </div>
                                <div class="left">
                                    <asp:TextBox ID="txtHanKiemDinh" runat="server"></asp:TextBox>
                                </div>
                            </td>
                        </tr>
                          
                        <tr>
                            <td class="crmcell right">
                                Nhân viên lập biên bản</td>
                            <td class="crmcell">
                                <div class="left width-200">
                                <asp:TextBox ID="txtNhanVienLapBienBan" runat="server" Width="90px"></asp:TextBox>
                                <asp:Button ID="btnBrowseNhanVienBienBan" runat="server" CausesValidation="false" 
                                        CssClass="pickup" OnClick="btnBrowseNhanVienBB_Click" 
                                        OnClientClick="openDialogAndBlock('Chọn từ danh sách nhân viên', 800, 'divNhanVienBB')" 
                                        UseSubmitBehavior="false" />
                                    <asp:TextBox ID="txtTenNhanVienLapBB" runat="server" ReadOnly="True"></asp:TextBox>
                                </div>
                                
                            </td>
                        </tr>
                          
                        <tr>    
                            <td class="crmcell right">Ghi chú</td>
                            <td class="crmcell">
                                <div class="left">
                                    <asp:TextBox ID="txtGhiChu" TextMode="MultiLine" Rows="3" Width="525" MaxLength="500" runat="server" />
                                </div>
                            </td>
                        </tr>  
                        <tr>    
                            <td class="crmcell right"></td>
                            <td class="crmcell">    
                                <div class="left">
                                    <eoscrm:Button ID="btnSave" runat="server" CssClass="save" OnClick="btnSave_Click" 
                                        TabIndex="13" UseSubmitBehavior="false" />
                                </div>
                                <div class="left">
                                    <eoscrm:Button ID="btnDelete" runat="server" CssClass="delete" OnClick="btnDelete_Click"
                                        TabIndex="19" UseSubmitBehavior="false" />
                                        </div>
                                        <div class="left">
                                    <eoscrm:Button ID="btnHuy" runat="server" CssClass="cancel" onclick="btnHuy_Click" />
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>  
    <br />
    <asp:UpdatePanel ID="upnlGrid" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            <div class="crmcontainer">
                <eoscrm:Grid ID="gvKhachHang" runat="server" UseCustomPager="true" PageSize="20"
                    OnRowCommand="gvKhachHang_RowCommand" OnPageIndexChanging="gvKhachHang_PageIndexChanging"
                    OnRowDataBound="gvKhachHang_RowDataBound" >
                    <PagerSettings FirstPageText="khách hàng" PageButtonCount="2" />
                    <Columns>
                        <asp:TemplateField HeaderStyle-CssClass="checkbox">
                            <HeaderTemplate>
                                <input id="chkAllTop" title="Chọn hết / Bỏ chọn hết" name="chkAllTop" type="checkbox"
                                    onclick="CheckAllItems(this);" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <input id="Id" runat="server" type="hidden" value='<%# Eval("ID") %>' />
                                <input name="listIds" type="checkbox" value='<%# Eval("ID") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-CssClass="checkbox" HeaderText="#">
                            <ItemTemplate>
                                <%# Container.DataItemIndex + 1%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderStyle-Width="8%" HeaderText="Mã KH">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkBtnID" runat="server" CommandArgument='<%# Eval("ID") %>'
                                    CommandName="EditHoSo" Text='<%# Eval("KHACHHANG.MADP") + Eval("KHACHHANG.DUONGPHU").ToString() + Eval("KHACHHANG.MADB") %>'></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField> 
                        <asp:TemplateField HeaderStyle-Width="25%" HeaderText="Tên khách hàng">
                            <ItemTemplate>
                                <%# Eval("KHACHHANG.TENKH")%>
                            </ItemTemplate>
                            <HeaderStyle Width="25%" />
                        </asp:TemplateField>   
                        <asp:TemplateField HeaderStyle-Width="40%" HeaderText="Địa chỉ">
                            <ItemTemplate>
                                <%# String.IsNullOrEmpty(Eval("KHACHHANG.SONHA").ToString()) ? "" : Eval("KHACHHANG.SONHA") + ", "%>
                                <%# Eval("KHACHHANG.DUONGPHO.TENDP")%>, <%# Eval("KHACHHANG.PHUONG.TENPHUONG")%>, <%# Eval("KHACHHANG.KHUVUC.TENKV")%>
                            </ItemTemplate>
                            <HeaderStyle Width="35%" />
                        </asp:TemplateField>  
                        <asp:TemplateField HeaderStyle-Width="18%" HeaderText="Tình trạng" >
                            <ItemTemplate>
                                <%# (Eval("TINHTRANG") != null) ? ((bool.Parse(Eval("TINHTRANG").ToString())==true)?"Đã thay":
    "Chưa thay"):"Chưa thay"%>
                            </ItemTemplate>
                            <HeaderStyle Width="18%" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="18%" HeaderText="Ngày LBB">
                            <ItemTemplate>
                                <%# (Eval("NGAYLBB") != null) ?
                                        String.Format("{0:dd/MM/yyyy}", Eval("NGAYLBB"))
                                        : "" %>
                            </ItemTemplate>
                            <HeaderStyle Width="18%" />
                        </asp:TemplateField> 
                        <asp:TemplateField HeaderStyle-Width="18%" HeaderText="Ngày thay">
                            <ItemTemplate>
                                <%# (Eval("NGAYTD") != null) ?
                                        String.Format("{0:dd/MM/yyyy}", Eval("NGAYTD"))
                                        : "" %>
                            </ItemTemplate>
                            <HeaderStyle Width="18%" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="23%" HeaderText="Ngày hoàn thành">
                            <ItemTemplate>
                                <%# (Eval("NGAYHT") != null) ?
                                     String.Format("{0:dd/MM/yyyy}", Eval("NGAYHT"))
                                        : "" %>
                            </ItemTemplate>
                            <HeaderStyle Width="18%" />
                        </asp:TemplateField>
                    </Columns>
                </eoscrm:Grid> 
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
